<?php
require('lib/verify.php');
require('lib/has_char.php');
require('lib/is_approved.php');
require('lib/is_admin.php');

$_category = "warmath";
$_title = "Admin / Add a Credit";
require('lib/head.php');

$system_id = $system["system_id"];

$raid_id = $_GET["id"];
$sql = "select * from wm_raids  left join wm_instances on wm_instances.instance_id = raid_instance where wm_raids.raid_system_id = $system_id and raid_id = $raid_id";

$result = $db->query($sql);
$raid = $db->fetch_assoc($result);

if($_GET["error"]!="") {
  boxRed("Error");
?>
    <?=$_GET["error"]?>
<?php
    boxBot();
    }

boxTop("Warmath: $_title");
?>
<b>Add a Credit</b><br />
to 
<a href="raid.php?id=<?=$raid["raid_id"]?>"><?=$raid["instance_name"]?>, <?=date("D d M Y", strtotime($raid["raid_date"]))?></a>
<br /><br />

<form action="add-credit-2.php" method="post">
<input type="hidden" value="<?=$system["system_id"]?>" name="system_id">
<input type="hidden" value="<?=$_GET["id"]?>" name="raid_id">
<i>Boss</i><br />
<select name="boss">
<?php
$sql = "select * from wm_bosses where boss_instance = " . $raid["raid_instance"];
$result = $db->query($sql);
while($boss = $db->fetch_assoc($result)) {
  if(!$boss["boss_trash"]) {
?>
<option value="<?=$boss["boss_id"]?>"><?=$boss["boss_name"]?>
<?php
   }
    }
?>
</select>
<br /><br />
<i>Date and Time</i><br />
<?php
//if it's within 24h of the raid_date, use now's date
//date_select(strtotime($raid["raid_date"])) at time_select()
?>
<?date_select(strtotime(date(DATE_RFC822)))?> at <?time_select()?>
<br /><br />
<i>Attending</i>
<i>(List player names, one per line)</i><br />
<textarea name="attendance" rows=25>
</textarea>
<br />
<br />
<i>Sitting Out</i>
<i>(List player names, one per line)</i><br />
<textarea name="satout" rows=5>
</textarea>
<br />
<br />
<input type="submit" value="Add Credit">
</form>
<?php
boxBot();
?>

<?php
require('lib/foot.php');
?>

